package repo

import (
	"gitee.com/mkwchecking/sr-core/domain/dao"
	"gitee.com/mkwchecking/sr-core/domain/dao/scope"
)

type IRepo[Ent any] interface {
	Dao() dao.IDao[Ent]
	EntBuilder(func(*Ent)) scope.IScope

	// Find 查找
	Find(cds ...any) (*Ent, error)
	FindWithPK(id any, cds ...any) (*Ent, error)
	FindMulti(pageNum, pageSize int, cds ...any) ([]*Ent, int64, error)
	FindMultiWithPK(ids []any, cds ...any) ([]*Ent, int64, error)
	FindWithEnt(ent any, cds ...any) (*Ent, error)
	FindMultiWithEnt(pageNum, pageSize int, ent any, cds ...any) ([]*Ent, int64, error)

	// Update 更新
	Update(ent *Ent, cds ...any) (*Ent, error)
	UpdateWithEnt(ent *Ent, where any, cds ...any) (*Ent, error)

	// Create 创建
	Create(ent *Ent, cds ...any) (*Ent, error)
	CreateMulti(ents []*Ent, cds ...any) (int64, error)

	// Delete 删除
	SoftDeleteWithPK(id any, cds ...any) error
	SoftDeleteWithEnt(where any, cds ...any) error

	ForceDeleteWithPK(id any, cds ...any) error
	ForceDeleteWithEnt(where any, cds ...any) error

	// 关联
	Association(model *Ent, column string, cds ...any) (dao.IAssociation, error)
}
